import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/income_invoice_entity.dart';

IncomeInvoiceEntity $IncomeInvoiceEntityFromJson(Map<String, dynamic> json) {
  final IncomeInvoiceEntity incomeInvoiceEntity = IncomeInvoiceEntity();
  final String? cargo = jsonConvert.convert<String>(json['cargo']);
  if (cargo != null) {
    incomeInvoiceEntity.cargo = cargo;
  }
  final String? showTab = jsonConvert.convert<String>(json['showTab']);
  if (showTab != null) {
    incomeInvoiceEntity.showTab = showTab;
  }
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    incomeInvoiceEntity.email = email;
  }
  final List<
      IncomeInvoiceRelateCases>? relateCases = (json['relateCases'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<IncomeInvoiceRelateCases>(
          e) as IncomeInvoiceRelateCases).toList();
  if (relateCases != null) {
    incomeInvoiceEntity.relateCases = relateCases;
  }
  final List<
      IncomeInvoiceOrderAttach>? orderAttachs = (json['orderAttachs'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<IncomeInvoiceOrderAttach>(
          e) as IncomeInvoiceOrderAttach).toList();
  if (orderAttachs != null) {
    incomeInvoiceEntity.orderAttachs = orderAttachs;
  }
  final String? taxid = jsonConvert.convert<String>(json['taxid']);
  if (taxid != null) {
    incomeInvoiceEntity.taxid = taxid;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    incomeInvoiceEntity.address = address;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    incomeInvoiceEntity.phone = phone;
  }
  final String? bankname = jsonConvert.convert<String>(json['bankname']);
  if (bankname != null) {
    incomeInvoiceEntity.bankname = bankname;
  }
  final String? bankacct = jsonConvert.convert<String>(json['bankacct']);
  if (bankacct != null) {
    incomeInvoiceEntity.bankacct = bankacct;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    incomeInvoiceEntity.remark = remark;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    incomeInvoiceEntity.title = title;
  }
  return incomeInvoiceEntity;
}

Map<String, dynamic> $IncomeInvoiceEntityToJson(IncomeInvoiceEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['cargo'] = entity.cargo;
  data['showTab'] = entity.showTab;
  data['email'] = entity.email;
  data['relateCases'] = entity.relateCases?.map((v) => v.toJson()).toList();
  data['orderAttachs'] = entity.orderAttachs?.map((v) => v.toJson()).toList();
  data['taxid'] = entity.taxid;
  data['address'] = entity.address;
  data['phone'] = entity.phone;
  data['bankname'] = entity.bankname;
  data['bankacct'] = entity.bankacct;
  data['remark'] = entity.remark;
  data['title'] = entity.title;
  return data;
}

extension IncomeInvoiceEntityExtension on IncomeInvoiceEntity {
  IncomeInvoiceEntity copyWith({
    String? cargo,
    String? showTab,
    String? email,
    List<IncomeInvoiceRelateCases>? relateCases,
    List<IncomeInvoiceOrderAttach>? orderAttachs,
    String? taxid,
    String? address,
    String? phone,
    String? bankname,
    String? bankacct,
    String? remark,
    String? title,
  }) {
    return IncomeInvoiceEntity()
      ..cargo = cargo ?? this.cargo
      ..showTab = showTab ?? this.showTab
      ..email = email ?? this.email
      ..relateCases = relateCases ?? this.relateCases
      ..orderAttachs = orderAttachs ?? this.orderAttachs
      ..taxid = taxid ?? this.taxid
      ..address = address ?? this.address
      ..phone = phone ?? this.phone
      ..bankname = bankname ?? this.bankname
      ..bankacct = bankacct ?? this.bankacct
      ..remark = remark ?? this.remark
      ..title = title ?? this.title;
  }
}

IncomeInvoiceRelateCases $IncomeInvoiceRelateCasesFromJson(
    Map<String, dynamic> json) {
  final IncomeInvoiceRelateCases incomeInvoiceRelateCases = IncomeInvoiceRelateCases();
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    incomeInvoiceRelateCases.caseId = caseId;
  }
  final String? caseName = jsonConvert.convert<String>(json['caseName']);
  if (caseName != null) {
    incomeInvoiceRelateCases.caseName = caseName;
  }
  final String? time = jsonConvert.convert<String>(json['time']);
  if (time != null) {
    incomeInvoiceRelateCases.time = time;
  }
  return incomeInvoiceRelateCases;
}

Map<String, dynamic> $IncomeInvoiceRelateCasesToJson(
    IncomeInvoiceRelateCases entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseId'] = entity.caseId;
  data['caseName'] = entity.caseName;
  data['time'] = entity.time;
  return data;
}

extension IncomeInvoiceRelateCasesExtension on IncomeInvoiceRelateCases {
  IncomeInvoiceRelateCases copyWith({
    String? caseId,
    String? caseName,
    String? time,
  }) {
    return IncomeInvoiceRelateCases()
      ..caseId = caseId ?? this.caseId
      ..caseName = caseName ?? this.caseName
      ..time = time ?? this.time;
  }
}

IncomeInvoiceOrderAttach $IncomeInvoiceOrderAttachFromJson(
    Map<String, dynamic> json) {
  final IncomeInvoiceOrderAttach incomeInvoiceOrderAttach = IncomeInvoiceOrderAttach();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    incomeInvoiceOrderAttach.name = name;
  }
  final String? url = jsonConvert.convert<String>(json['url']);
  if (url != null) {
    incomeInvoiceOrderAttach.url = url;
  }
  return incomeInvoiceOrderAttach;
}

Map<String, dynamic> $IncomeInvoiceOrderAttachToJson(
    IncomeInvoiceOrderAttach entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['url'] = entity.url;
  return data;
}

extension IncomeInvoiceOrderAttachExtension on IncomeInvoiceOrderAttach {
  IncomeInvoiceOrderAttach copyWith({
    String? name,
    String? url,
  }) {
    return IncomeInvoiceOrderAttach()
      ..name = name ?? this.name
      ..url = url ?? this.url;
  }
}